/*
 *  CEScrollMenu.h
 *  LID Library
 *
 *  Created by Alexander Trutchenko on 09/11/11.
 *  Copyright 2011 League of Independent Developers. All rights reserved.
 *
 */

#ifndef __CE_ScrollMenu_h__
#define __CE_ScrollMenu_h__


#include "cocos2dx_extentions/controls/CEMenu.h"


namespace cocosext {

#define CE_SCROLLMENU_ITEM_ACTIVATE_TIME 0.2f
#define CE_SCROLLMENU_ITEM_TAP_TIME 1.f

/////////////////////////////////////////////////////
//
/** CEScrollMenu 
* Menu which works closly with CEScrollView, which is its ancestor
*/
/////////////////////////////////////////////////////

class CEScrollView;

class CEScrollMenu : public CEMenu
{
	CEScrollView* _scrollView;
	bool _scrollViewTouchBegan;
	bool _scrollViewTouchLost;
	bool _scrollTapTimerExpired;
	bool _activateTimerExpired;
	cocos2d::CCPoint _startPoint;

protected:
	CEScrollMenu(int touchPriority, CEScrollView* scrollView);

public:
    virtual ~CEScrollMenu() {;}

	    /* Static constructor */
    static CEScrollMenu* node(int touchPriority, CEScrollView* scrollView);

protected:
    virtual bool init();

public:
	CEScrollView* scrollableArea() const { return _scrollView; }

//Cocos2d interface


// Touch processing
	virtual bool ccTouchBegan(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
    virtual void ccTouchMoved(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
    virtual void ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);
    virtual void ccTouchCancelled(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent);

private:
	void onActivateTimerExpired(cocos2d::ccTime delta);
	void onTapTimerExpired(cocos2d::ccTime delta);

}; //CEScrollMenu


}; // end namespace cocosext

#endif // __CE_ScrollMenu_h__
